package com.example.administrator.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * Created by Administrator on 2020/11/19.
 */

public class TwoActivity extends AppCompatActivity {

    private Button finishBtn;
    private EditText usernameEd;
    private EditText scoreEd;
    private EditText ispassedEd;
    private Button startActivityBtn;
    private String studentName;
    private String scoreStr;
    private String ispassedStr;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_two);
        initView();
       
        initEvent();
    }
    private void initView(){
        finishBtn = findViewById(R.id.activity_finish_btn);
        usernameEd = findViewById(R.id.username_et);
        scoreEd= findViewById(R.id.score_et);
        ispassedEd = findViewById(R.id.ispassed_et);
        startActivityBtn = findViewById(R.id.startactivity_btn);
    }
    private void initData(){
        studentName = usernameEd.getText().toString()+"";
        scoreStr = scoreEd.getText().toString()+"";
        ispassedStr = ispassedEd.getText().toString()+"";
    }
    private void initEvent(){
     finishBtn.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {

             finish();//关闭当前的activity

         }
     });
     startActivityBtn.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
             initData();
             //创建intent对象
             Intent intent = new Intent(TwoActivity.this,ThreeActivity.class);
             intent.putExtra("studentName",studentName);
             Toast.makeText(TwoActivity.this,"姓名"+studentName,Toast.LENGTH_SHORT).show();
         }
     });
    }


}
